package com.Action;

import javax.annotation.Resource;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import com.service.UserService;
import com.user.User;

public class UserAction extends ActionSupport implements ModelDriven {
	private User user;
	@Resource(name="UserService")
	private UserService userservice;
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public UserService getUserservice() {
		return userservice;
	}
	public void setUserservice(UserService userservice) {
		this.userservice = userservice;
	}
	@Override
	public String execute() throws Exception {
		if(userservice==null){
			return "Login";
		}
		if(userservice.save(user)){
			return "success";
		}
		return "fail";
	}
	@Override
	public Object getModel() {
		if(user==null){
			user = new User();
		}
		return user;
	}


}
